CC=g++
FLAGS=-Wall -s -O3
CLIBS = -lpthread

# Link commands:
all: main

alles: main test

test: motorTest muisTest threadTest serialTest moterSturingTest movingObjectTest

pieter: bin/waypointTest bin/movingObjectTest bin/strategieTest bin/rijTest

kristof: bin/infraroodTest

# Dit stukje is van Pieter
# Je kan nu $(objects) gebruiken om aan alle objecten te geraken!  Joepie!  Jeeeuuujj!!! Feestje!!!!
# AWESOME!!!!
# voor voorbeeld zie bin/strategieTest

allsources= besturing.cpp infrarood.cpp motors.cpp movement.cpp muis.cpp serial.cpp strategie.cpp thread.cpp vision.cpp movingObject/movingObject.cpp movingObject/waypoint.cpp

sources := $(addprefix source/,$(allsources))

objects := $(patsubst %.cpp,%.o,$(addprefix compile/,$(allsources)))
#Tot hier is het pieterstuk

main: main.o robot.o besturing.o muis.o thread.o motors.o serial.o movement.o
	$(CC) $(FLAGS) compile/main.o compile/robot.o compile/besturing.o compile/muis.o compile/motors.o compile/thread.o compile/serial.o compile/movement.o -o bin/robotje -lpthread

motorTest: motor.o serial.o compile/thread.o
	$(CC) $(FLAGS) compile/motor.o compile/serial.o compile/thread.o -o bin/motorTest -lpthread

muisTest: muisTest.o compile/thread.o muis.o
	$(CC) $(FLAGS) compile/muisTest.o compile/muis.o compile/thread.o -o bin/muisTest -lpthread

threadTest: threadTest.o compile/thread.o
	$(CC) $(FLAGS) compile/threadTest.o compile/thread.o -o bin/threadTest -lpthread	

serialTest: serial.o serialTest.o
	$(CC) $(FLAGS) compile/serialTest.o compile/serial.o -o bin/serialTest -lpthread	

bin/waypointTest: compile/movingObject/waypoint.o compile/movingObject/waypointTest.o
	$(CC) $(FLAGS) compile/movingObject/waypoint.o compile/movingObject/waypointTest.o -o bin/waypointTest -lpthread

bin/movingObjectTest: compile/movingObject/movingObject.o compile/movingObject/movingObjectTest.o compile/movingObject/waypoint.o compile/thread.o
	$(CC) $(FLAGS) compile/movingObject/movingObject.o compile/movingObject/movingObjectTest.o compile/movingObject/waypoint.o compile/thread.o -o bin/movingObjectTest -lpthread

bin/strategieTest: compile/strategieTest.o $(objects)
	$(CC) $(FLAGS) $(CLIBS) compile/strategieTest.o $(objects) -o bin/strategieTest 

bin/infraroodTest: compile/infraroodTest.o compile/infrarood.o compile/thread.o
	$(CC) $(FLAGS) compile/infraroodTest.o compile/infrarood.o compile/thread.o -o bin/infraroodTest -lpthread
	
bin/rijTest: compile/rijTest.o $(objects)
	$(CC) $(FLAGS) $(CLIBS) compile/rijTest.o $(objects) -o bin/rijTest 


# compilation commands:



main.o: compile/main.o

compile/main.o: source/main.cpp
	$(CC) $(FLAGS) -c source/main.cpp -o compile/main.o

robot.o: compile/robot.o

compile/robot.o: source/robot.cpp source/robot.h
	$(CC) $(FLAGS) -c source/robot.cpp -o compile/robot.o

muis.o: compile/muis.o

compile/muis.o: source/muis.cpp source/muis.h
	$(CC) $(FLAGS) -c source/muis.cpp -o compile/muis.o

muisTest.o: source/muisTest.cpp 
	$(CC) $(FLAGS) -c source/muisTest.cpp -o compile/muisTest.o

muismove.o: compile/muismove.o

compile/muismove.o: source/muismove.cpp source/muismove.h
	$(CC) $(FLAGS) -c source/muismove.cpp -o compile/muismove.o

motors.o: compile/motors.o

compile/motors.o: source/motors.cpp source/motors.h
	$(CC) $(FLAGS) -c source/motors.cpp -o compile/motors.o

serial.o: compile/serial.o

compile/serial.o: source/serial.cpp source/serial.h
	$(CC) $(FLAGS) -c source/serial.cpp -o compile/serial.o

thread.o: compile/thread.o

compile/thread.o: source/thread.cpp source/thread.h
	$(CC) $(FLAGS) -c source/thread.cpp -o compile/thread.o
	
besturing.o: compile/besturing.o

compile/besturing.o: source/besturing.cpp source/besturing.h
	$(CC) $(FLAGS) -c source/besturing.cpp -o compile/besturing.o

movement.o: compile/movement.o

compile/movement.o: source/movement.cpp source/movement.h
	$(CC) $(FLAGS) -c source/movement.cpp -o compile/movement.o

threadTest.o: source/threadTest.cpp
	$(CC) $(FLAGS) -c source/threadTest.cpp -o compile/threadTest.o	

serialTest.o: source/serialTest.cpp
	$(CC) $(FLAGS) -c source/serialTest.cpp -o compile/serialTest.o	
	
motorSturingTest.o: source/motorSturingTest.cpp
	$(CC) $(FLAGS) -c source/motorSturingTest.cpp -o compile/motorSturingTest.o

infrarood.o: compile/infrarood.o

compile/infrarood.o: source/infrarood.cpp
	$(CC) $(FLAGS) -c source/infrarood.cpp -o compile/infrarood.o

compile/movingObject/waypoint.o: source/movingObject/waypoint.cpp source/movingObject/waypoint.h
	$(CC) $(FLAGS) -c source/movingObject/waypoint.cpp -o compile/movingObject/waypoint.o

compile/movingObject/waypointTest.o:	source/movingObject/waypointTest.cpp source/movingObject/waypoint.h
	$(CC) $(FLAGS) -c source/movingObject/waypointTest.cpp -o compile/movingObject/waypointTest.o

compile/movingObject/movingObject.o:	source/movingObject/movingObject.cpp source/movingObject/movingObject.h source/thread.h
	$(CC) $(FLAGS) -c source/movingObject/movingObject.cpp -o compile/movingObject/movingObject.o

compile/movingObject/movingObjectTest.o:	source/movingObject/movingObjectTest.cpp
	$(CC) $(FLAGS) -c source/movingObject/movingObjectTest.cpp -o compile/movingObject/movingObjectTest.o

compile/strategie.o: source/strategie.cpp source/strategie.h
	$(CC) $(FLAGS) -c source/strategie.cpp -o compile/strategie.o

compile/strategieTest.o: source/strategieTest.cpp source/strategie.h
	$(CC) $(FLAGS) -c source/strategieTest.cpp -o compile/strategieTest.o 
	
compile/rijTest.o: source/rijTest.cpp
	$(CC) $(FLAGS) -c source/rijTest.cpp -o compile/rijTest.o 

compile/vision.o : source/vision.cpp source/vision.h
	$(CC) $(FLAGS) -c source/vision.cpp -o compile/vision.o

#compile/infrarood.o : source/infrarood.cpp source/infrarood.h
#	$(CC) $(FLAGS) -c source/infrarood.cpp -o compile/infrarood.o

compile/motorSturing.o: source/motorSturing.cpp source/motorSturing.h
	$(CC) $(FLAGS) -c source/motorSturing.cpp -o compile/motorSturing.o

compile/infraroodTest.o: source/infraroodTest.cpp source/infrarood.h
	$(CC) $(FLAGS) -c source/infraroodTest.cpp -o compile/infraroodTest.o

# clean:
clean: 
	-rm -f bin/* compile/*.o compile/*/*.o

